<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<script type="text/javascript">
	function endProcess(processId) {

		isperp.confirmAlert("您确定要结束此流程？", {
			yes : function() {
				$.post("workflow/processRun/endProcess?processId=" + processId, function(data) {
					isperp.tooltip("流程结束！");
					allTaskListGrid.reload();
				});

			}
		});

	}

	function deleteProcess(processId) {

		isperp.confirmAlert("您确定要删除此流程？", {
			yes : function() {
				$.post("workflow/processRun/deleteProcess?processId=" + processId, function(data) {
					isperp.tooltip("流程结束！");
					allTaskListGrid.reload();
				});

			}
		});

	}

	function processAction(rowObject) {

		var action = "";
		var processKey = rowObject.procDefId.split(":")[0];

		action += isperp.createGridAction({
			title : "流程跟踪",
			iconCls : "icon-preview",
			onclick : "isperp.openDialog({contentUrl:'workflow/processRun/traceView?processId=" + rowObject.procInstId + "'})"
		});
		action += isperp.createGridAction({
			title : "查看详细",
			iconCls : "icon-view",
			onclick : "isperp.openDialog({contentUrl:'workflow/processRun/entryProcess?processKey=" + processKey + "&processId=" + rowObject.procInstId + "'})"
		});

		action += isperp.createGridAction({
			title : "终止流程",
			iconCls : "ui-icon-pencil",
			onclick : "endProcess('" + rowObject.procInstId + "')"
		});

		action += isperp.createGridAction({
			title : "删除流程",
			iconCls : "ui-icon-trash",
			onclick : "deleteProcess('" + rowObject.procInstId + "')"
		});
		return action;
	}
	function allTaskMenuTree_onNodeClick2(event, treeId, treeNode) {

		if (treeNode.id == '1') {
			$("#suspensionState").val("1")
		} else {

			$("#suspensionState").val("0")
		}
		allTaskMenuTree_onNodeClick(event, treeId, treeNode);
	}
</script>
<div class="container_0 clearfix">
	<div class="box no-border">
		<div class="header">
			<h2>${pageTitle}</h2>
		</div>
		<isperp:grid url="workflow/processRun/allTaskList" datatype="local"
			ondbClickRowEvent="" gridId="allTaskListGrid"
			gridTitle="${pageTitle}" cusFormatterActions="true"
			cusDialogSize="big" actionsWidth="120"
			cusActions="processAction(rowObject)" sortname="createTime"
			sortorder="desc"
			afterGridCreate="allTaskMenuTree_onNodeClickFirst();">
			<jsp:attribute name="searchbar">
				<input type="hidden" value="1" id="suspensionState"
					field="suspensionState_" op="eq" class="constvalue">
				<table class="search-table">
					<tbody>
						<tr>
							<td class="td1">节点名称：</td>
							<td class="td2"><input type="text" field="name" op="cn">
							</td>
						</tr>
					</tbody>
				</table>
			</jsp:attribute>
			<jsp:attribute name="toolbar">
				<isperp:treeMenu id="allTaskMenu" targetGridId="allTaskListGrid"
					nodes="[{id:1,name:'进行中'},{id:2,name:'已结束'}]">
					<isperp:async enable="false"></isperp:async>
					<isperp:data simpleData="true"></isperp:data>
					<isperp:callback onClick="allTaskMenuTree_onNodeClick2">
					</isperp:callback>
				</isperp:treeMenu>
			</jsp:attribute>

			<jsp:body> 
				<isperp:column name="id" title="id" hidden="true"></isperp:column>
				
				<isperp:column name="procInstId" title="procInstId" hidden="true"></isperp:column>
				<isperp:column name="name" title="节点名称" width="100">
				</isperp:column>
				<isperp:column name="createTime" title="创建时间" width="80">
				</isperp:column>
				<isperp:column name="procDefId" title="流程定义" width="100"></isperp:column>
			
			</jsp:body>
		</isperp:grid>
	</div>


</div>
